package com.liang.jiekou.mapper;


import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.liang.jiekou.entity.COPTC;
import com.liang.jiekou.entity.COPTD;
import com.liang.jiekou.entity.PURTC;
import com.liang.jiekou.entity.PURTD;
import com.liang.jiekou.entity.result.COPTCD;
import com.liang.jiekou.entity.result.PURTCD;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PURTCDMapper {
    //查询采购单单头
    @DS("demo")
    PURTC selectPURTC(String TC001, String TC002);


    //查询采购单单身
    @DS("demo")
    List<PURTD> selectPURTD(String TC001, String TC002);

    @DS("demo")
    @Select("SELECT TD010 FROM PURTD WHERE TD001 = '3310' AND TD002 = #{TD002} AND TD003= #{TD003}")
    Double selectOne(String TD002,String TD003);

//    //查询采购单单头
//    @DS("demo")
//    List<PURTC> selectPURTCall();
//
//
//    //查询采购单单身
//    @DS("demo")
//    List<PURTD> selectPURTDall();


    @DS("demo")
    IPage<PURTC> selectPURTCall(Page<PURTCD> page, String startcreate, String endcreate, String startupdate, String endupdate);


    //查询客户订单单身
    @DS("demo")
    IPage<PURTD> selectPURTDall(Page<PURTCD> page, String startcreate, String endcreate, String startupdate, String endupdate);

    @DS("demo")
    @Select("SELECT COUNT(TD012) FROM PURTD WHERE " +
            "TD012 < CAST(GETDATE() AS DATE) " +
            "AND TD001 = '3310' " +
            "AND TD002 = #{cd011} " +
            "AND TD003 = #{cd012} ")
    Boolean selectCQ(String cd011, String cd012);

    @DS("demo")
    List<PURTC> selectPurtcListByCreateDateWithModiDate(String startcreate, String endcreate, String startupdate, String endupdate);

    @DS("demo")
    @Select("select * from PURTD where TD001 = #{tc001} and TD002 = #{tc002}")
    List<PURTD> selectPurtdList(String tc001, String tc002);
}
